package cn.iocoder.yudao.module.wine.controller.app.agreement;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.wine.controller.app.agreement.vo.AppAgreementRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.agreement.AgreementDO;
import cn.iocoder.yudao.module.wine.service.agreement.AgreementService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @author zyc
 * @createDate 2024/6/4 11:34
 */
@Tag(name = "用户 APP - 协议模块")
@RestController
@RequestMapping("/wine/agreement")
@Validated
public class AppAgreementController {


    @Resource
    private AgreementService agreementService;

    @GetMapping("/get-supply")
    @Operation(summary = "获得供求协议")
    public CommonResult<AppAgreementRespVO> getSupplyAgreement() {
        AgreementDO agreementDO = agreementService.getSupplyAgreement();
        return success(BeanUtils.toBean(agreementDO, AppAgreementRespVO.class));
    }

    @GetMapping("/get-poster")
    @Operation(summary = "获得海报")
    public CommonResult<AppAgreementRespVO> getPosterAgreement() {
        AgreementDO agreementDO = agreementService.getPosterAgreement();
        return success(BeanUtils.toBean(agreementDO, AppAgreementRespVO.class));
    }

    @GetMapping("/get-register")
    @Operation(summary = "获得注册协议")
    public CommonResult<AppAgreementRespVO> getRegisterAgreement() {
        AgreementDO agreementDO = agreementService.getRegisterAgreement();
        return success(BeanUtils.toBean(agreementDO, AppAgreementRespVO.class));
    }

    @GetMapping("/get-vip")
    @Operation(summary = "获得vip协议")
    public CommonResult<AppAgreementRespVO> getVipAgreement() {
        AgreementDO agreementDO = agreementService.getVipAgreement();
        return success(BeanUtils.toBean(agreementDO, AppAgreementRespVO.class));
    }

    @GetMapping("/get")
    @Operation(summary = "根据参数获得协议")
    public CommonResult<AppAgreementRespVO> getVipAgreement(@RequestParam("type") Integer type) {
        AgreementDO agreementDO = agreementService.appGetAgreement(type);
        return success(BeanUtils.toBean(agreementDO, AppAgreementRespVO.class));
    }
}
